<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<HEAD><TITLE> Messages retrieved from server </TITLE></HEAD>
<BODY>
<?php
require ("smsconn.php");
$si = new SmsInterface ();
if (!$si->connect ($username, $password, true,
false))
	echo "<P> Unable to connect to the SMS server.\n";
elseif (($srl = $si->checkReplies (false)) === NULL) {
	echo "Unable to read messages from the SMS server.\n";
if ($si->getResponseMessage () !== NULL)
	echo "<BR>Reason: " . $si->getResponseMessage() . "\n";
} elseif (count ($srl) == 0)
	echo "No messages waiting on the SMS server.\n";
else {
	echo "<TABLE w><TR>";
	echo "<td> Message ID </td><td> Phone number</td><td> Message</td><td> Status</td></tr>";
	foreach ($srl as $sr) {
		echo "<TR><TD> $sr->messageID</TD> <TD> $sr->phoneNumbe</TD><TD>$sr->message</TD><TD>";
		if ($sr->status == MessageStatus::none ())
			echo "None";
		elseif ($sr->status == MessageStatus::pending ())
			echo "Message delivery pending";
		elseif ($sr->status == MessageStatus::delivered ())
			echo "Message successfully delivered";
		elseif ($sr->status == MessageStatus::failed ())
			echo "Message delivery failed";
		else
			echo "Unknown message status '$sr->status'";
		echo "</TD></TR>";
	}
	echo "</TABLE>";
}
?>
</BODY>
</HTML>